package com.shire.shire_interface.service.group.impl;

import com.shire.shire_interface.dao.group.WxGroupMemberDao;
import com.shire.shire_interface.model.group.WxGroupMember;
import com.shire.shire_interface.model.group.WxGroupMemberExample;
import com.shire.shire_interface.service.group.WxGroupMemberService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 作者:  sll
 * 时间:  2019/7/26 17:20
 */
@Service
public class WxGroupMemberServiceImpl implements WxGroupMemberService {

    @Resource
    private WxGroupMemberDao wxGroupMemberDao;

    @Override
    public List<WxGroupMember> groupMembers(WxGroupMemberExample example) {

            return wxGroupMemberDao.selectByExample(example);

    }

    @Override
    public List<WxGroupMember> selectByExample(WxGroupMemberExample example1) {
        return wxGroupMemberDao.selectByExample(example1);
    }

    @Override
    public int deleteByExample(WxGroupMemberExample example) {
        return wxGroupMemberDao.deleteByExample(example);
    }

    @Override
    public WxGroupMember getGroupMember(Integer csId, String groupNo, String wxId) {
        WxGroupMemberExample memberExample = new WxGroupMemberExample();
        memberExample.createCriteria().andGroupnoEqualTo(groupNo).andWxidEqualTo(wxId).andStatusEqualTo(0);

        List<WxGroupMember> members = wxGroupMemberDao.selectByExample(memberExample);
        if (members != null && members.size() > 0)
            return members.get(0);
        return null;
    }

    @Override
    public Integer insertBySelective(WxGroupMember wxGroupMember) {
        return wxGroupMemberDao.insertSelective(wxGroupMember);
    }
}
